﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Alice.Parser
{
    internal class Token
    {
        internal Token(string text, int line, int charNum, bool convertString)
        {
            if (convertString)
            {
                text = text.Substring(1, text.Length - 2);
                //\t\r\n\f\"
                text = text.Replace("\\t", "\t").Replace("\\r", "\r").Replace("\\n", "\n").Replace("\\f", "\f").Replace("\\\"", "\"");
            }

            Text = text;
            Line = line;
            CharNum = charNum;
        }
        internal Token(double value, int line, int charNum)
        {
            Numeric = value;
            Line = line;
            CharNum = charNum;
        }
        internal Token(int value, int line, int charNum)
        {
            Numeric = value;
            Line = line;
            CharNum = charNum;
        }
        internal Token(int line, int charNum)
        {
            Line = line;
            CharNum = charNum;
        }

        internal String Text;
        internal double Numeric;
        internal int Line;
        internal int CharNum;

        public override string ToString()
        {
            if (Text != null)
                return Text;
            return string.Format("{0}", Numeric);
        }
    }
}
